﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Web.Mvc;

namespace ProjectBase.Core
{
    [ContractClass(typeof(Diagnostics.EntityFacade<,>))]
    public interface IEntityFacade<TEntity, in TID>
        : IReadFacade<TEntity, TID>
          , IWriteFacade<TEntity, TID>
          , IEntityBinder<TEntity, TID>
        where TEntity : class, IPersistentObjectWithTypedId<TID>
    {
        /// <summary>
        ///     Expects the source file (Excel 2007+) to be passed, and imported
        /// </summary>
        /// <param name = "dataSource"></param>
        /// <param name="processor"></param>
        bool Import(byte[] dataSource, Action<IValueProvider> processor = null);

        /// <summary>
        ///     Can be current entity edited
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool CanBeEdited(TEntity entity);
        /// <summary>
        ///     Can be current entity deleted
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool CanBeDeleted(TEntity entity);
    }
    /// <summary>
    ///     Facades (EntityFacades) represents the middle tier
    ///     between DAO and any upper layer.
    ///     Data are manipulated with (Ioc set) IDao instance;
    ///     but passed from or to upper layer when the Busines rules are met.
    ///     Facades are responsible for Add, Edit and Delete checks (fitting the Business rules)
    ///     as well as for corret Filter settings to be passed to IDao
    ///     (e.g. the lowest DateTime boundary for SQL Server is not the same
    ///     as the lowest value for DateTime in .NET)
    /// </summary>
    /// <typeparam name = "TEntity"></typeparam>
    /// <typeparam name = "TID"></typeparam>
    /// <typeparam name = "TFilter"></typeparam>
    [ContractClass(typeof(Diagnostics.EntityFacade<,,>))]
    public interface IEntityFacade<TEntity, in TID, TFilter>
        : IEntityFacade<TEntity, TID>
        , IReadFacade<TEntity, TID, TFilter>
        where TEntity : class, IPersistentObjectWithTypedId<TID>
        where TFilter : class, IFilter<TID>
    {
        /// <summary>
        ///     Deletes all items, meeting filtering criteria
        /// </summary>
        /// <param name = "filter"></param>
        bool DeleteAll(TFilter filter);
    }
}